package org.wzy.design.patterns.proxy.custom;

import java.lang.reflect.Method;

import org.wzy.design.patterns.proxy.jdk.Person;

/** 
 * ClassName: GPMeipo <br/> 
 * Function: TODO ADD FUNCTION. <br/> 
 * Reason: TODO ADD REASON(可选). <br/> 
 * date: 2017年6月15日 上午12:02:24 <br/> 
 * 
 * @author wzy_h 
 * @version  
 * @since JDK 1.8
 */
public class GPMeipo implements GPInvocationHandler {

	private Person target;

	// 获取被代理人的个人资料
	@SuppressWarnings("rawtypes")
	public Object getInstance(Person target) throws Exception {
		this.target = target;
		Class clz = target.getClass();
		System.out.println("被代理对象的class是：" + clz);
		return GPProxy.newProxyInstance(new GPClassLoader(), clz.getInterfaces(), this);
	}
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("我是媒婆，得给你找个异性！");
		System.out.println("开始进行海选......");
		
		System.out.println("-------------------------------");
		
//		target.findLover();
		
		System.out.println("-------------------------------");
		
		System.out.println("如果合适的话，就准备办事儿！");
		
		return null;
	}
}
